<template>
  <div>
    <h2>修改投资</h2>
    <table class="table table-bordered">
      <tr>
        <td>投资名称</td>
        <td>
          <input type="text" v-model="sdate.I_Name" />
        </td>
      </tr>
      <tr>
        <td>投资总额度</td>
        <td>
          <input type="text" v-model="sdate.I_Zong" />
        </td>
      </tr>
      <tr>
        <td></td>
        <td><input type="button" value="添加投资" @click="add" /></td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, onMounted } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
let router = useRouter();
let route = useRoute();

let data: any = reactive({
  sdate: {},
});
let { sdate } = toRefs(data);

onMounted(() => {
  Show();
});

const Show = () => {
  axios({
    url: 'http://localhost:61995/api/User/Fan',
    method: 'get',
    params: {
      I_Id: route.query.I_Id,
    },
  }).then((res) => {
    console.log(res);
    sdate.value = res.data.data;
  });
};

const add = () => {
  axios({
    url: 'http://localhost:61995/api/User/Gai',
    method: 'post',
    data: sdate.value,
  }).then((res) => {
    console.log(res.data);
    if (res.data.data > 0) {
      alert('修改成功');
      router.push('/show');
    }
  });
};
</script>

<style scoped></style>
